﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;

namespace PixelDetectSDKInterface
{
	public class PixelType
	{
		// 当前人脸算法生成的人脸关键点个数
		public const int PIXEL_FACE_POINT = 81;

		//当前姿势估计算法生成的骨骼关键点个数
		public const int PIXEL_POSE_POINT = 17;
	}

	[StructLayout(LayoutKind.Sequential)]
	public struct PixelParam
	{
		public int flag;           // 有效性判断，请不要乱改该值
		public int thread_num;     // 指定同时多少线程参与运算,0默认全部参与
		public int device_id;      // 指定加速设备的id号, 当前只支持GPU,如果对应的算法架构没GPU版本，该参数无效
		public int device_memory;  // 指定加速设备最大可用内存的百分比,当前只支持GPU,范围0-100
		
		[MarshalAs(UnmanagedType.ByValArray, SizeConst = 256)]
		public char[] model_folder;  // 指定模型所在的文件夹路径
		
		[MarshalAs(UnmanagedType.ByValArray, SizeConst = 128)]
		public char[] reserved; // 预留
	}

	// 特征点结构体
	[StructLayout(LayoutKind.Sequential)]
	public struct PixelPoint
	{
		public float x;
		public float y;
	}

	// 矩形框结构体
	[StructLayout(LayoutKind.Sequential)]
	public struct PixelRect
	{
		public int x;
		public int y;
		public int width;
		public int height;
	};

	// 人脸检测结果结构体
	[StructLayout(LayoutKind.Sequential)]
	public struct PixelFaceResult
	{
		public PixelRect rect;
		public float score;
		public PixelPoint[] points;
	};

	// 人脸属性结构体
	[StructLayout(LayoutKind.Sequential)]
	public struct PixelFaceAttribute
	{
		public float roll;
		public float pitch;
		public float yaw;

		public int gender;
		public int age;
		public int emotion;
	};

	// 人脸特征结构体
	[StructLayout(LayoutKind.Sequential)]
	public struct PixelFaceFeature
	{
		public int length;
		public IntPtr feature;
	};

	// 身份证结构体
	[StructLayout(LayoutKind.Sequential)]
	public struct PixelIDCard
	{
		[MarshalAs(UnmanagedType.ByValArray, SizeConst = 40)]
		public char[] name;

		[MarshalAs(UnmanagedType.ByValArray, SizeConst = 4)]
		public char[] gender;

		[MarshalAs(UnmanagedType.ByValArray, SizeConst = 20)]
		public char[] nationality;

		[MarshalAs(UnmanagedType.ByValArray, SizeConst = 10)]
		public char[] birthdate;
		
		[MarshalAs(UnmanagedType.ByValArray, SizeConst = 512)]
		public char[] address;
		
		[MarshalAs(UnmanagedType.ByValArray, SizeConst = 20)]
		public char[] idno;
	};

	// 物体检测结果结构体
	[StructLayout(LayoutKind.Sequential)]
	public struct PixelObjectResult
	{
		public PixelRect rect;
		public float score;
		public int type;
	};

	// 姿势估计检测结果结构体
	[StructLayout(LayoutKind.Sequential)]
	public struct PixelPoseEstimationResult
	{
		[MarshalAs(UnmanagedType.ByValArray, SizeConst = 17)]
		public PixelPoint[] points;

		[MarshalAs(UnmanagedType.ByValArray, SizeConst = 17)]
		public float[] score;

		public int action;
	};
}
